package com.zh.note.huawei.onehundred.阿里巴巴找黄金宝箱2;

import java.util.*;

/**
 * https://dream.blog.csdn.net/article/details/130962198
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // String inputStr = sc.nextLine();
        String inputStr = "6,6,6,6,3,3,3,1,1,5";
        String[] split = inputStr.split(",");
        Map<String, Integer> map = new HashMap<>();

        for (String str : split) {
            map.put(str, map.getOrDefault(str, 0) + 1);
        }

        List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
        //以出现的次数多少，由大到小排序进行排序
        list.sort((o1, o2) -> o2.getValue() - o1.getValue());
        int count = 0;
        int res = 0;
        double temp = split.length / 2;
        int half = (int) Math.ceil(temp);
        for (Map.Entry<String, Integer> entry : list) {
            count += entry.getValue();
            res++;
            if (count >= half) {
                break;
            }
        }
        System.out.println(res);
    }
}
